﻿using System;
using TYBase;

namespace TYRTUBase.Comm
{
    public class IRDataHelper
    {
        public static bool DataToIR(string data, out double ocv, out double ir)
        {
            var data_tmp = data.Split(',');
            if (data_tmp.Length != 2)
            {
                ocv = 0;
                ir = 0;
                return false;
            }
            ir = Math.Abs(data_tmp[0].AsDouble()) * 1000;
            ocv = Math.Abs(data_tmp[1].AsDouble()) * 1000;
            return true;
        }

        public static string OCVIR_2_String(double ocv, double ir)
        {
            return $"{(ir / 1000).ToString()},{(ocv / 1000).ToString()}";
        }
    }
}